%% start here multi_partition
clc;
clear;
%mypic = rgb2gray(imread('./pics/bahama.jpg'));
mypic = imread('./pics/tst2.pgm');
res = multi_partition(edge(mypic),0.6);
figure
imshow(res)


%% regular partition with gradient instead of sobel edge
mypic = imread('./pics/tst2.pgm');
[Px,Py] = gradient(double(mypic));
t = 15;
x = (Px.^2+Py.^2).^0.5;
map = ((x>t).*x)/max(max(x));
imshow(uint8((x > t).*x))
%map = edge(mypic);
res = multi_partition(map,0.3, [0.0,0.05,0.05,0.05,0.0]);
figure
imshow(res);

%% printing the edge map
figure
colormap(gray(256));
image(edge(mypic)*255);
daspect([1 1 1]);
axis off;
